
/**
 * COOKIE存储
 * @author xxt
 * @param {String} key 
 * @param {Object} val 
 * @param {Number} time 
 */
function setcookie(key,val,time = 10){
    if(typeof val == 'object') val = JSON.stringify(val)
    const d = new Date
    d.setTime(d.getTime() - 1000*60*60*8 +1000*time)
    document.cookie = `${key}=${val}; expires=${d}`
}

/**
 * COOKIE获取
 * @author xxt
 * @param {String} key 
 * @returns String
 */
function getcookie(key){
    let arr = document.cookie.split(';')
    for(let i=0; i<arr.length;i++){
        let item = arr[i]
        let tempArr = item.split('=')
        if(tempArr[0] == key) return tempArr[1]
    }
}

/**
 * COOKIE删除
 * @author xxt
 * @param {String} key 
 * @returns undefined
 */
function removecookie(key){
    setcookie(key,null,-1)
}




